Consider X_i \stackrel{iid}{\sim} N\left(\mu, 2^2\right) with n=25. We wish to test H_0: \mu = 0 versus H_1: \mu = 1. We need to choose k so that
\alpha = P\left(\overline{X} > k\ |\ \mu = 0\right) = 1 - \Phi\left(\frac{k-0}{2/\sqrt{25}}\right)
and
\beta = P\left(\overline{X} < k\ |\ \mu = 1\right) = \Phi\left(\frac{k-1}{2/\sqrt{25}}\right)
In pictures, for k = 0.4 this looks like:
Suppose that we “thump” a “fair” coin ten times. For testing {H}_0 : p = 0.5 versus the one-sided alternative {H}_1 : p > 0.5 at the \alpha = 0.05 level we note that P(X>7\ |\ p = 0.5) = 1 - P(X \le 7\ |\ p = 0.5) =
1-pbinom(7, 10, 0.5)
[1] 0.0546875
pbinom(7, 10, 0.5, lower.tail =FALSE)
[1] 0.0546875
Since 0.0546875 > \alpha = 0.05 we check P(X > 8\ |\ p = 0.5) = 1 - P(X \le 7\ |\ p = 0.5) =
1-pbinom(8, 10, 0.5)
[1] 0.01074219
pbinom(8, 10, 0.5, lower.tail =FALSE)
[1] 0.01074219
Since 0.0107422 < \alpha = 0.05 we reject {H}_0 when X > 8, “flip a coin” with P({reject}) = p^* when X = 8, and do not reject {H}_0 when X \le 7.